﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LTJ.Common;
using LTJ.Entity;
using LTJ.FrameWork;
namespace uswinweb.admin
{
    public partial class basedatatype_add : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SASRequest.IsPost())
            {
                AddBaseType();
            }
        }
        protected void AddBaseType()
        {
            string code = SASRequest.GetFormString("codetxt").Trim();
            string tname = SASRequest.GetFormString("tnametxt").Trim();
            string etname = SASRequest.GetFormString("etnametxt").Trim();
            string expo = "";
            LTJ.Entity.BType bt = new LTJ.Entity.BType();
            int i = 1;
            foreach (LTJ.Entity.BType btt in Enum.GetValues(bt.GetType()))
            {
                if (SASRequest.GetString("expo" + i) != "")
                {
                    expo += SASRequest.GetString("expo" + i) + ",";
                }
                i++;
            }
            string msg = BaseTypes.CreateBaseType(code, tname, etname, expo.Trim(','));

            if (msg != "")
            {
                base.RegisterStartupScript("PAGE", "parent.document.getElementById('reclick').click();parent.Lightview.hide();");
            }
            else
            {
                if (msg == "")
                {
                    base.RegisterStartupScript("PAGETEMPLATE", "此基础数据类型已存在！");
                }
                else
                {
                    base.RegisterStartupScript("PAGETEMPLATE", "基础数据类型添加失败!");
                }
            }
            
        }
    }
}